<?php
	session_start();
	require_once("banco.php");
	if(isset($_SESSION['idusuario'])) {
		//lista do usuario
		$result = mysql_query("select v.videoId,v.titulo from videos v, pref_video p where p.videoId=v.videoId and p.lista=1 and p.idusuario=" . addslashes($_SESSION['idusuario']) . " ORDER BY RAND()");
	}else{
		//Qualquer coisa
		$result = mysql_query("select v.videoId,v.titulo from videos v, pref_video p where p.videoId=v.videoId and p.lista=1 ORDER BY RAND()");
	}
?>
<html>
<head>
<title>Vinil de Queijo</title>
	<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="swfobject.js"></script>
	<script type="text/javascript" src="queijotube.js"></script>
	<script type="text/javascript">
	var lista = [<?php
		if($obj = mysql_fetch_object($result)){
			echo '{videoId: "' . $obj->videoId . '",titulo:"' . addslashes($obj->titulo) . '"}';
		}
		while ($obj = mysql_fetch_object($result)){
			echo ',{videoId: "' . $obj->videoId . '",titulo:"' . addslashes($obj->titulo) . '"}';
		}
	?>];
	</script>
	<style>
		#ytapiplayer{
			width: 50%;
		}
		#frmLogin{

		}
		#frmCadastro,
		#frmLogin,
		#playList{
			width: 50%;
		}
		#playList{
			position: absolute;
			right: 5px;
			top: 4px;
		}
	</style>
</head>
<body>
	<div id="ytapiplayer">
		You need Flash player 8+ and JavaScript enabled to view this video.
	</div>
	<form action="login.php" id="frmLogin" onsubmit="return login(this)">
		<fieldset>
			<legend>Entrar</legend>
			<div>
				<label for="email">E-mail</label>
				<input type="text" id="email" name="email" />
			</div>
			<div>
				<label for="senha">Senha</label>
				<input type="password" id="senha" name="senha" />
			</div>
			<input type="submit" value="Ok">
		</fieldset>
	</form>
	<form action="cadastro.php" id="frmCadastro" onsubmit="return newUsuario(this)">
		<fieldset>
			<legend>Cadastro de Usu&aacute;rio</legend>
			<div>
				<label for="nome">Nome</label>
				<input type="text" id="nome" name="nome" />
			</div>
			<div>
				<label for="email">E-mail</label>
				<input type="text" id="email" name="email" />
			</div>
			<div>
				<label for="senha">Senha</label>
				<input type="password" id="senha" name="senha" />
			</div>
			<div>
				<label for="confSenha">Confirme a senha</label>
				<input type="password" id="confSenha" name="confSenha" />
			</div>
			<input type="submit" value="Ok">
		</fieldset>
	</form>
	<div id="playList">
		<form action="incluirVideo.php" id="frmIncluirVideo" onsubmit="return cadastrar(this)">
			<fieldset>
				<legend>Cadastrar V&iacute;deo</legend>
				<div>
					<label for="youtubeId">Url:</label><input type="text" id="youtubeId" name="youtubeUrl" /><input type="submit" value="Ok">
				</div>
			</fieldset>
		</form>
		<a href="javascript: proximo()">Pr&oacute;ximo</a>
		<ol id="lista"></ol>
	</div>
</body>
</html>